// 判断用户是否登录
var username = getCookie('username')
var age
var gender
var nickname
  $.ajax({
        url: 'http://localhost:8888/users/info?id='+getCookie('userId'),
        headers: {
            authorization: localStorage.getItem('token') || ''
        }
    }).then(res => {
        console.log(res);
        if(res.code === 1){
            var html = `
                <tr>
                    <td>用户名：</td>
                    <td>${res.info.username} </td>
                </tr>
                <tr>
                    <td>昵称：</td>
                    <td><input type="text"></td>
                </tr>
                <tr>
                    <td>身份：</td>
                    <td>${res.info.identity} </td>
                </tr>
               <tr>
                <td>性别：</td>
                <td><input type="text"> </td>
              </tr>
              <tr>
                <td>年龄：</td>
                <td><input type="text"> </td>
              </tr>
              <tr>  
                  <td></td>
                  <td>
                      <input type="button" value="提交修改">
                  </td>
              </tr>
            `
            $('.rightcontent tbody').html(html)


 $(':button').click(function () {
    $.ajax({
        url: 'http://localhost:8888/users/update?id='+getCookie('userId'),
         type: 'post',
            dataType: 'json',
            data: {
                username: getCookie('username'),
                id: getCookie('userId'),
                age:$(":text").eq(2).val(),
                gender:$(":text").eq(1).val(),
                nickname:$(":text").eq(0).val()
            },
        headers: {
            authorization: localStorage.getItem('token') || ''
        }
    }).then(res => {
        console.log(res);
        if(res.code === 1){
           console.log(res);
        }

    })
})


        }

    })

